﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Microsoft.MSE.Catalog.Module.Configuration
{
    /// <summary>
    /// 
    /// </summary>
    public static class SettingsManager
    {
        /// <summary>
        /// 
        /// </summary>
        public static class Repository
        {
            private static string _sqlServer;
            private static string _sqlDatabase;

            public static string SqlServer
            {
                set { _sqlServer = value; }
            }

            public static string SqlDatabase
            {
                set { _sqlDatabase = value; }
            }

            public static string ConnectionString
            {
                get
                {
                    const string template = "Data Source={0};Initial Catalog={1};MultipleActiveResultSets=True;Integrated Security=SSPI";

                    //use value from config or command line values
                    if (!string.IsNullOrEmpty(_sqlServer) && !string.IsNullOrEmpty(_sqlDatabase))
                    {
                        string connectionString = string.Format(template, _sqlServer, _sqlDatabase);
                        return connectionString;
                    }

                    return null;
                }
            }
        }
    }
}
